package ae.pcfc.etks.online.itworx.ehs.web.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.validation.constraints.Pattern;

import ae.pcfc.etks.online.itworx.ehs.web.constants.GlobalConstants;
import ae.pcfc.etks.online.itworx.ehs.web.enums.RequestStatus;

public class RequestSearchCriteria implements Serializable{

	@Pattern(regexp = GlobalConstants.REQUEST_ID_REGEXP)
	private String viewRequestId;
	private long requestId;
	private String requestStatus;
	private String companyNameEn;
	private String companyNameAr;
	private Date submissionDate;
	private Date receivedDate;
	private int pageNumber = 1;
	private int totalPageNumber;
	private int totalResultSize;
	private String sortField;
	private boolean assending;
	private boolean firstPage;
	private boolean lastPage;
	private String requestType;
	private Date creationDate;
	private String serviceName;
	private String type;
	private List<RequestStatus> statuses;
	private List<RequestStatus> clientStatuses;
	private List<RequestStatus> officerStatuses;

	public List<RequestStatus> getClientStatuses() {
		if(clientStatuses == null){
			clientStatuses = new ArrayList<RequestStatus>();
			clientStatuses.add(RequestStatus.Additional_Payment_Required);
			clientStatuses.add(RequestStatus.Approved);
			clientStatuses.add(RequestStatus.Non_Compliance_Comments_Exists);
			clientStatuses.add(RequestStatus.Return_For_Update);
		}
		return clientStatuses;
	}

	public void setClientStatuses(List<RequestStatus> clientStatuses) {
		this.clientStatuses = clientStatuses;
	}

	public List<RequestStatus> getOfficerStatuses() {
		if(officerStatuses == null){
			officerStatuses = new ArrayList<RequestStatus>();
			officerStatuses.add(RequestStatus.Additional_Payment_Done);
			officerStatuses.add(RequestStatus.Comments_Replied);
			officerStatuses.add(RequestStatus.Inspection_Approved);
			officerStatuses.add(RequestStatus.Inspection_In_Progress);
			officerStatuses.add(RequestStatus.Payment_Confirmed);
			officerStatuses.add(RequestStatus.Payment_Done);
			officerStatuses.add(RequestStatus.Resubmitted);
			officerStatuses.add(RequestStatus.Submitted);
		}
		return officerStatuses;
	}

	public void setOfficerStatuses(List<RequestStatus> officerStatuses) {
		this.officerStatuses = officerStatuses;
	}

	public String getViewRequestId() {
		return viewRequestId;
	}

	public void setViewRequestId(String viewRequestId) {
		this.viewRequestId = viewRequestId;
	}
	
	public String getRequestType() {
		return requestType;
	}

	public void setRequestType(String requestType) {
		this.requestType = requestType;
	}

	public Date getCreationDate() {
		return creationDate;
	}

	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}

	public String getServiceName() {
		return serviceName;
	}

	public void setServiceName(String serviceName) {
		this.serviceName = serviceName;
	}

	public List<RequestStatus> getStatuses() {
		if(statuses == null){
			statuses = new ArrayList<RequestStatus>();
			statuses.add(RequestStatus.Additional_Payment_Done);
			statuses.add(RequestStatus.Additional_Payment_Required);
			statuses.add(RequestStatus.Approved);
			statuses.add(RequestStatus.Canceled);
			statuses.add(RequestStatus.Closed);
			statuses.add(RequestStatus.Comments_Replied);
			statuses.add(RequestStatus.Inspection_Approved);
			statuses.add(RequestStatus.Inspection_In_Progress);
			statuses.add(RequestStatus.Non_Compliance_Comments_Exists);
			statuses.add(RequestStatus.Payment_Done);
			statuses.add(RequestStatus.Payment_Confirmed);
			statuses.add(RequestStatus.Resubmitted);
			statuses.add(RequestStatus.Return_For_Update);
			statuses.add(RequestStatus.Rejected);
			statuses.add(RequestStatus.Submitted);
		}
		return statuses;
	}

	public void setStatuses(List<RequestStatus> statuses) {
		this.statuses = statuses;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public Date getReceivedDate() {
		return receivedDate;
	}

	public void setReceivedDate(Date receivedDate) {
		this.receivedDate = receivedDate;
	}
	
	public int getTotalPageNumber() {
		return totalPageNumber;
	}

	public void setTotalPageNumber(int totalPageNumber) {
		this.totalPageNumber = totalPageNumber;
	}

	public boolean isFirstPage() {
		return firstPage;
	}

	public void setFirstPage(boolean firstPage) {
		this.firstPage = firstPage;
	}

	public boolean isLastPage() {
		return lastPage;
	}

	public void setLastPage(boolean lastPage) {
		this.lastPage = lastPage;
	}
		

	public String getSortField() {
		return sortField;
	}

	public void setSortField(String sortField) {
		this.sortField = sortField;
	}

	public boolean isAssending() {
		return assending;
	}

	public void setAssending(boolean assending) {
		this.assending = assending;
	}

	public int getPageNumber() {
		return pageNumber;
	}

	public void setPageNumber(int pageNumber) {
		this.pageNumber = pageNumber;
	}

	public int getTotalResultSize() {
		return totalResultSize;
	}

	public void setTotalResultSize(int totalResultSize) {
		this.totalResultSize = totalResultSize;
	}

	public Date getSubmissionDate() {
		return submissionDate;
	}

	public void setSubmissionDate(Date submissionDate) {
		this.submissionDate = submissionDate;
	}

	public long getRequestId() {
		return requestId;
	}

	public void setRequestId(long requestId) {
		this.requestId = requestId;
	}

	public String getRequestStatus() {
		return requestStatus;
	}

	public void setRequestStatus(String requestStatus) {
		this.requestStatus = requestStatus;
	}

	public String getCompanyNameEn() {
		return companyNameEn;
	}

	public void setCompanyNameEn(String companyNameEn) {
		this.companyNameEn = companyNameEn;
	}

	public String getCompanyNameAr() {
		return companyNameAr;
	}

	public void setCompanyNameAr(String companyNameAr) {
		this.companyNameAr = companyNameAr;
	}
	
	public void setFirstAndLastPageFlags(){
		
		if(this.pageNumber == totalPageNumber)
		{
			this.lastPage=true;
		}
		else
		{
			this.lastPage=false;
		}
		if(this.pageNumber == 1)
		{
			this.firstPage=true;
		}
		else
		{
			this.firstPage =false;
		}
	}

}
